package com.lan.seriousphysics.screens.experimentos;

import java.text.DecimalFormat;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.input.GestureDetector.GestureListener;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.lan.seriousphysics.SeriousPhysicsMain;
import com.lan.seriousphysics.screens.AbstractScreen;
import com.lan.seriousphysics.screens.experimentMenus.MRUScreen;

public class MRUExperimento extends AbstractScreen implements GestureListener, InputProcessor {

	Label lTit;
	Label lEcuacion;
	Label lDescrip;
	Label lDescrip2;

	public MRUExperimento(SeriousPhysicsMain game) {
		super(game);
		// TODO Auto-generated constructor stub
	}

	public void show() {
		super.show();

		setBackground("fondo.png");

		previousScreen = new MRUScreen(game, "MRU");

		Gdx.input.setInputProcessor(new InputMultiplexer(this, new GestureDetector(this)));

		Table table = super.getTable();

		lDescrip = new Label(res.getString("MRUD1"), getSkin(), "menus");
		table.add(lDescrip).spaceBottom(50);
		table.row();

		lDescrip2 = new Label(res.getString("MRUD2"), getSkin(), "menus");
		table.add(lDescrip2).spaceBottom(50);
		table.row();

		lTit = new Label(res.getString("VELOCIDAD"), getSkin());
		table.add(lTit).spaceBottom(50);
		table.row();

		lEcuacion = new Label(res.getString("ECUACION") + "s=s0 + vt",
				getSkin());
		table.add(lEcuacion).spaceBottom(50);
		table.row();

	}

	@Override
	public boolean touchDown(float x, float y, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean tap(float x, float y, int count, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean longPress(float x, float y) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean fling(float velocityX, float velocityY, int button) {
		// TODO Auto-generated method stub
		// 1 m = 5334 pixels
		DecimalFormat df = new DecimalFormat("0.00");

		Float velocidad = Math.abs(velocityX / 5334);

		lTit.setText(res.getString("VELOCIDAD") + velocidad + " m/s");
		lEcuacion.setText(res.getString("ECUACION") + "s=s0 +"
				+ df.format(velocidad) + "t");
		return false;
	}

	@Override
	public boolean pan(float x, float y, float deltaX, float deltaY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean zoom(float initialDistance, float distance) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
			Vector2 pointer1, Vector2 pointer2) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyDown(int keycode) {
		if(keycode == Keys.BACK){
        	game.setScreen(previousScreen);
        }
		return false;
	}

	@Override
	public boolean keyUp(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyTyped(char character) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return false;
	}

}
